import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

export default defineConfig({
  plugins: [vue()],
  base: './',
  build: {
    outDir: 'dist',
    rollupOptions: {
      input: {
        main: path.resolve(__dirname, 'pop/index.html'),
        background: path.resolve(__dirname, 'background/background.ts'),
        options: path.resolve(__dirname, 'options/index.html')
      },
      output: {
        entryFileNames: ({ facadeModuleId, isEntry }) => {
          const file = facadeModuleId || '';
          const dir = path.dirname(file).split('/');
          const lastDir = dir[dir.length - 1];
          const name = path.basename(file, path.extname(file)); // notes;
          return `${lastDir}/${name}.js`;
        },
        //   assetFileNames: (val) => {
        //     const name = path.basename(val.name || ''); // notes;

        //     console.log('aaaaaaaa', name)

        //     return "a" + name;
        //   },
        //   chunkFileNames: (val) => {
        //     const name = path.basename(val.name || ''); // notes;
        //     return "a" + name;
        //   }

      },
    }
  }
})
